﻿using Basic.FlowCollect;
using Basic.FlowModel.DB;
using Basic.FlowRemoteModel.NodeMsg.Model;
using Basic.FlowService.Interface;
using WeDonekRpc.Client;

namespace Basic.FlowService.lmpl
{
    internal class FlowNodeMsgService : IFlowNodeMsgService
    {
        private readonly INodeMsgCollect _Service;
        public FlowNodeMsgService ( INodeMsgCollect service )
        {
            this._Service = service;
        }
        public bool Set ( long id, NodeMsgSet set )
        {
            DBFlowNodeMsg msg = this._Service.Get(id);
            return this._Service.Set(msg, set);
        }
        public void Add ( NodeMsgSet msg )
        {
            this._Service.Add(msg);
        }
        public FlowNodeMsg[] Gets ( long nodeId )
        {
            return this._Service.GetsByNode<FlowNodeMsg>(nodeId);
        }

        public FlowNodeMsgData Get ( long id )
        {
            DBFlowNodeMsg msg = this._Service.Get(id);
            return msg.ConvertMap<DBFlowNodeMsg, FlowNodeMsgData>();
        }

        public void Delete ( long id )
        {
            DBFlowNodeMsg msg = this._Service.Get(id);
            this._Service.Delete(msg);
        }
    }
}
